<template>
  <div>
    <!--  -->
    <crumbs @goBack="goBack" :superiorMenu="['质量管理']" currentMenu="不合格品处理明细"></crumbs>
    <a-card :bordered="false" style="height:100%;margin-top:12px">
      <a-button @click="handleShowFilter" icon="filter">筛选 <span class="filter-num" style="margin-left:5px">{{ ' '+ filteredNums }}</span></a-button>
      <a-button @click="showColumn" icon="unordered-list" class="btns">设置列</a-button>
      <div class="right-btn">
        <!-- <a-button @click="importFile">导入</a-button>
        <a-button @click="exportFile" class="btns">导出</a-button> -->
        <!-- <a-button @click="handleAdd"  type="primary" icon="plus" class="btns">新建</a-button> -->
      </div>
      <a-table
        row-key="id"
        :key="tableKey"
        size="middle"
        :scroll="{ x: scrollX, y: 'calc(100vh - 366px)' }"
        :hideDefaultSelections="false"
        :row-selection="{ selectedRowKeys: selectedRowKeys, columnTitle:' ', onChange: onSelectChange}"
        :columns="columns"
        :dataSource="modelList"
        :pagination="false"
         @change="tableChange"
        style="margin-top:24px"
        :components="drag(columns, 'DEFECTS_DEAL_DETAIL')"
      >
        <span slot="actions" slot-scope="text, record">
          <a @click="handleDelete(record)">删除</a>
        </span>
        <!-- 行信息 -->
        <span slot="orderCode" slot-scope="text, record" :title="text" class="btn-text" @click="orderDetail(record)">
          {{ record.orderCode }}
        </span>
        <div slot="batchCode" slot-scope="text, record" class="btn-text ant-table-row-cell-ellipsis" :title="text" @click="batchRecord(record)">{{text|| '-'}}</div>
        <span slot="goodsName" :title="record.goodsName" slot-scope="text, record">
          {{  record.goodsName  }}
        </span>
        <span slot="spec" :title="record.spec" slot-scope="text, record">
          {{  record.spec  }}
        </span>
        <span slot="basicUnitText" :title="record.basicUnitText" slot-scope="text, record">
          {{  record.basicUnitText  }}
        </span>
        <span slot="num" :title="record.num" slot-scope="text, record">
          {{ numFormat(record.num) }}
        </span>
        <!-- 输入框搜索 -->
        <div slot="searchInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class='searchWorkOreder'>
          <a-input placeholder='请输入' v-model="filterForm[column.dataIndex]" style="width: 188px;display: block;"
            @pressEnter="handleSearch" />
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => handleSearch(selectedKeys, confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="searchIcon" slot-scope="filtered" type="search" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 选择搜索 -->
        <div slot="selectDropdown" slot-scope="{confirm, clearFilters, column}" class='searchWorkOreder'>
          <a-select mode="multiple" placeholder="请选择" allowClear style="width: 188px" v-model="filterForm['handleType']" @change="(v) => changeStatus(v, 'handleType')">
            <a-select-option value="repair">返修</a-select-option>
            <a-select-option value="compromise">让步接收</a-select-option>
            <a-select-option value="scrap">报废</a-select-option>
          </a-select>
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => handleSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="selectIcon" slot-scope="filtered" type="filter" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 日期搜索 -->
        <div slot="datePicker" slot-scope="{confirm, clearFilters, column}" class='searchWorkOreder'>
          <a-range-picker
            style="width:188px"
            format="YYYY-MM-DD"
            v-model="dateForm[column.dataIndex]"
            :placeholder="['开始时间', '结束时间']"
            @change="onOk"
          />
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => handleSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="dateIcon" slot-scope="filtered" type="filter" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 人员选择 -->
        <div slot="selectPeople" slot-scope="{confirm, clearFilters, column }" class='searchWorkOreder'>
          <j-select-user-by-dep @changeRow="userFilter" v-model="userIds" :limit="5" :seldep='true' :modalWidth="1000" :multi="true"></j-select-user-by-dep>
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => handleSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="peopleIcon" slot-scope="filtered" type="filter" :style="{ color: filtered ? '#108ee9' : undefined }" />
      </a-table>
      <SetColumn
        columnName="设置列"
        ref="SetColumn"
        v-if="showSetColumn"
        @sureBtn="sureBtn"
        @cancelBtn="showSetColumn = false"
      />
    </a-card>
    <a-drawer
      placement="right"
      width="500"
      :visible="showFilter"
      @close="closeFilter"
    >
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">筛选 <span class="filter-num">{{ filteredNums }}</span></div>
        <div class="uni-card" v-if="filteredNums > 0" style="background:#fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="item.text" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float:right" />
            </span>
          </div>
        </div>
        <div style="overflow-y:scroll;flex:1;padding:0">
          <div class="uni-card" style="background:#fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="处理方式">
                <a-select mode="multiple" placeholder="请选择" allowClear style="width:100%" v-model="filterForm.handleType" @change="(v) => changeStatus(v, 'handleType')">
                  <a-select-option value="repair">返修</a-select-option>
                  <a-select-option value="compromise">让步接收</a-select-option>
                  <a-select-option value="scrap">报废</a-select-option>
                </a-select>
              </a-form-model-item>
              <a-form-model-item label="工单编号">
                <a-input v-model="filterForm.orderCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="批次编号">
                <a-input v-model="filterForm.batchCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="产品名称">
                <a-input v-model="filterForm.goodsName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="规格">
                <a-input v-model="filterForm.spec" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="不合格工序">
                <a-input v-model="filterForm.failedProcessName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="不合格操作人">
                <a-input v-model="filterForm.failedOperatorName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="工序名称">
                <a-input v-model="filterForm.processName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="处理人">
                <j-select-user-by-dep @changeRow="userFilter" v-model="userIds" :limit="5" :seldep='true' :modalWidth="1000" :multi="true"></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="处理时间">
                <a-range-picker
                  style="width:100%"
                  format="YYYY-MM-DD"
                  v-model="dateForm.handleTime"
                  :placeholder="['开始时间', '结束时间']"
                  @change="onOk"
                />
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <!-- 全选/分页 -->
    <div class="uni-card resetPadding" :style="{position: 'fixed', bottom:0,right:0,zIndex:2,left:collapsed?'79px':'208px', background: '#fff',paddingLeft:'43px'} ">
      <div style="display: inline-block">
        <a-checkbox :indeterminate="listIndeterminate" :checked="listCheckAll" @change="onCheckAllChange"></a-checkbox>
        <span class='btn-text' style="margin:0 24px" @click="batchAction">批量删除</span>
        <span style="margin-left: 8px">
          {{ `已选 ${selectedRowKeys.length}/${total} 项` }} <span class='btn-text' @click="clearArr" style="margin: 0 10px">清空</span>
        </span>
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination :total="total" v-model="current" :page-size-options="pageSizeOptions" :page-size="pageSize" @change="onChangePage" @showSizeChange="onShowSizeChange" show-quick-jumper
          show-size-changer />
      </div>
    </div>
    <batch-production ref="BatchProduction"></batch-production>
    <windowDetail ref="windowDetail"></windowDetail>
  </div>
</template>
<script>
import SetColumn from '@/pubComponent/SetColumn.vue'
import crumbs from '@/components/crumbs.vue'
import { getNewColumns, subStrText, camelCase2UnderLine, numFormat } from '@/utils/util'
import { API } from '@/api/requestFzs'
import moment from 'dayjs'
import { mapState } from 'vuex'
import tableDragResize from '@/mixins/tableDragResize'
import BatchProduction from '@/pubComponent/BatchProduction'
import windowDetail from '@/views/workManagement/workOrder/workOrderDetail'
// 表头
const columnsValue = [
  {
    title: '工单编号',
    fixed: 'left',
    dataIndex: 'orderCode',
    ellipsis: true,
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'orderCode',
    },
    sorter: true,
  },
  {
    title: '批次编号',
    dataIndex: 'batchCode',
    ellipsis: true,
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'batchCode',
    },
  },
  {
    title: '产品编号',
    ellipsis: true,
    dataIndex: 'goodsCode',
    width: 150,
  },
  {
    title: '产品名称',
    ellipsis: true,
    dataIndex: 'goodsName',
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'goodsName',
    }
  },
  {
    title: '规格',
    ellipsis: true,
    dataIndex: 'spec',
    width: 150,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'spec',
    }
  },
  {
    title: '不合格工序',
    ellipsis: true,
    width: 120,
    dataIndex: 'failedProcessName',
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'failedProcessName',
    }
  },
  {
    title: '不合格操作人',
    ellipsis: true,
    width: 120,
    dataIndex: 'failedOperatorName',
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'failedOperatorName',
    }
  },
  {
    title: '基本单位',
    ellipsis: true,
    dataIndex: 'basicUnitText',
    width: 150,
    scopedSlots: { customRender: 'basicUnitText' }
  },
  {
    title: '工序编号',
    dataIndex: 'processCode',
    ellipsis: true,
    width: 150,
  },
  {
    title: '工序名称',
    dataIndex: 'processName',
    width: 150,
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'processName',
    }
  },
  {
    title: '操作人',
    ellipsis: true,
    dataIndex: 'operatorIdText',
    width: 150,
  },
  {
    title: '报工单位',
    ellipsis: true,
    dataIndex: 'reportWorkUnitText',
    width: 150,
  },
  {
    title: '处理数量',
    dataIndex: 'num',
    width: 120,
    ellipsis: true,
    sorter: true,
    scopedSlots: { customRender: 'num' }
  },
  {
    title: '处理方式',
    ellipsis: true,
    dataIndex: 'handleTypeText',
    width: 120,
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'selectIcon',
      customRender: 'handleTypeText',
    },
  },
  {
    title: '提交人',
    ellipsis: true,
    dataIndex: 'applicantIdText',
    width: 120,
  },
  {
    title: '提交时间',
    ellipsis: true,
    dataIndex: 'applyTime',
    width: 180,
    sorter: true,
  },
  {
    title: '处理人',
    ellipsis: true,
    dataIndex: 'handlerIdText',
    width: 120,
    scopedSlots: {
      filterDropdown: 'selectPeople',
      filterIcon: 'peopleIcon',
      customRender: 'handlerIdText',
    },
  },
  {
    title: '处理时间',
    ellipsis: true,
    dataIndex: 'handleTime',
    width: 180,
    scopedSlots: {
      filterDropdown: 'datePicker',
      filterIcon: 'dateIcon',
      customRender: 'handleTime',
    },
    sorter: true,
  },
  // {
  //   fixed: 'right',
  //   title: '操作',
  //   align: 'left',
  //   dataIndex: 'actions',
  //   width: 100,
  //   ellipsis: true,
  //   scopedSlots: { customRender: 'actions' },
  // },
]
const actionArr = [{
  fixed: 'right',
  title: '操作',
  align: 'left',
  dataIndex: 'actions',
  ellipsis: true,
  width: 100,
  scopedSlots: { customRender: 'actions' },
}]
export default {
  mixins: [tableDragResize],
  data() {
    return {
      numFormat,
      moment,
      subStrText,
      //全选按钮
      listIndeterminate: false,
      listCheckAll: false,
      showFilter: false, // 筛选抽屉
      modelList: [], // 列表数据
      selectedRowKeys: [], // 列表已选择数据
      showSetColumn: false, // 显示
      colunmArr: [
        {
          checkAll: false,  //当前组是否全选
          indeterminate: false,  //当前组不全选且有选择项时显示状态
          checkedList: [],  //已选数据（不包括所有属性，只含有所选项的每一项的value）
          selectList: [],  //已选数据（包括所有属性）
          topTitle: '基础字段',  //当前组顶部字段
          plainOptions: [],    //当前组提供可供选择的选项
        },
      ],
      //全选按钮
      indeterminate: false,
      checkAll: false,
      current: 1,
      total: 0,
      pageSize: 10,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      columns: [
        {
          title: '工单编号',
          fixed: 'left',
          dataIndex: 'orderCode',
          ellipsis: true,
          width: 150,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'orderCode',
          },
          sorter: true,
        },
        {
          title: '批次编号',
          dataIndex: 'batchCode',
          ellipsis: true,
          width: 150,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'batchCode',
          },
        },
        {
          title: '产品名称',
          ellipsis: true,
          dataIndex: 'goodsName',
          width: 150,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsName',
          }
        },
        {
          title: '工序名称',
          dataIndex: 'processName',
          width: 150,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'processName',
          }
        },
        {
          title: '操作人',
          ellipsis: true,
          dataIndex: 'operatorIdText',
          width: 150,
        },
        {
          title: '报工单位',
          ellipsis: true,
          dataIndex: 'reportWorkUnitText',
          width: 150,
        },
        {
          title: '处理数量',
          dataIndex: 'num',
          ellipsis: true,
          width: 120,
          sorter: true,
          scopedSlots: { customRender: 'num' }
        },
        {
          title: '处理方式',
          ellipsis: true,
          dataIndex: 'handleTypeText',
          width: 120,
          scopedSlots: {
            filterDropdown: 'selectDropdown',
            filterIcon: 'selectIcon',
            customRender: 'handleTypeText',
          },
        },
        {
          title: '提交人',
          ellipsis: true,
          dataIndex: 'applicantIdText',
          width: 120,
        },
        {
          title: '提交时间',
          ellipsis: true,
          dataIndex: 'applyTime',
          width: 180,
          sorter: true,
        },
        {
          title: '处理人',
          ellipsis: true,
          dataIndex: 'handlerIdText',
          width: 120,
          scopedSlots: {
            filterDropdown: 'selectPeople',
            filterIcon: 'peopleIcon',
            customRender: 'handlerIdText',
          },
        },
        {
          title: '处理时间',
          ellipsis: true,
          dataIndex: 'handleTime',
          width: 180,
          scopedSlots: {
            filterDropdown: 'datePicker',
            filterIcon: 'dateIcon',
            customRender: 'handleTime',
          },
          sorter: true,
        },
        // {
        //   fixed: 'right',
        //   title: '操作',
        //   align: 'left',
        //   dataIndex: 'actions',
        //   width: 100,
        //   ellipsis: true,
        //   scopedSlots: { customRender: 'actions' },
        // },
      ],
      filterForm: {
        handleType: undefined,
        orderCode: '',
        batchCode: '',
        goodsName: '',
        processName: '',
        handlerId: '',
        handleTime: null,
        handleTimeBegin: '',
        handleTimeEnd: '',
      },
      filteredFormLable: {
        handleType: '处理方式',
        orderCode: '工单编号',
        batchCode: '批次编号',
        goodsName: '产品名称',
        processName: '工序名称',
        handlerId: '处理人',
        handleTime: '处理时间',
      },
      userIds: '', /* 选择的人员列表 */
      userNames: '', /* 选择的人员姓名 */
      sortForm: {
        sortType: '',
        sortColumn: '',
      },
      dateForm: {}, // 列表时间与筛选表单时间v-model同一个值
      parentId: '',
      tableKey: 1.9
    }
  },
  components: {
    SetColumn,
    crumbs,
    BatchProduction,
    windowDetail
  },
  computed: {
    scrollX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width) || 0
      }
      return xnum
    },
    ...mapState({
      collapsed: (state) => state.user.collapsed,
    }),
    hasSelected() {
      return this.selectedRowKeys.length > 0;
    },
    filteredList() {
      let list = []
      for(let key in this.filterForm) {
        if (key == 'handlerId') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.userNames,
            key
          })
        } else if (key == 'handleTime') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm.handleTimeBegin ? moment(this.filterForm.handleTimeBegin).format('YYYY-MM-DD') + '-' + moment(this.filterForm.handleTimeEnd).format('YYYY-MM-DD') : '',
            key
          })
        } else if (key == 'handleType' && this.filterForm[key]) {
          list.push({
            title: this.filteredFormLable[key],
            text: this.typeToText(this.filterForm[key]),
            key
          })
        } else if (key == 'handleTimeBegin' || key == 'handleTimeEnd') {
          // 什么事都不干
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key
          })
        }
      }
      return list
    },
    filteredNums() {
      let nums = 0
      for(let key in this.filterForm) {
        if (this.filterForm[key]) {
          nums += 1
          if (key == 'handleTimeBegin') {
            nums -= 1
          }
        }
      }
      return nums
    }
  },
  created() {
    if (this.$route.query.id) {
      this.parentId = this.$route.query.id
    }
    this.initData()
    this.requestData()
  },
  mounted() {
    console.log('filteredNums:',this.filteredNums)
  },
  methods: {
    // 批次生产记录弹窗列表
    batchRecord(record) {
      let obj = {
        id: record.batchId,
        orderId: record.orderId,
        batchCode: record.batchCode,
      }
      this.$refs.BatchProduction.showModal(obj, 'BATCH_PRODUCTION_DEFECTS_DEAL_DETAIL')
    },
    changeStatus(v, key) {
      if (v.length == 0) {
        this.filterForm[key] = undefined
      }
    },
    // 处理方式转文字
    typeToText(v) {
      let text = []
      let typeObj = {
        repair: '返修',
        compromise: '让步接收',
        scrap: '报废',
      }
      v.forEach(value => {
        text.push(typeObj[value])
      })
      return text.join(',')
    },
    // 排序
    tableChange(pagination, filters, sorter, { currentDataSource }) {
      console.log('看看这是啥33：', sorter)
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        this.sortForm = {
          sortType: sortType,
          sortColumn: camelCase2UnderLine(sorter.columnKey),
        }
        this.requestData()
      } else {
        this.sortForm = {
          sortType: '',
          sortColumn: '',
        }
        this.requestData()
      }
    },
    onOk(value) {
      if (value.length == 0) {
        this.filterForm.handleTimeBegin = ''
        this.filterForm.handleTimeEnd = ''
        this.filterForm.handleTime = ''
        return
      }
      this.filterForm.handleTimeBegin = moment(value[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
      this.filterForm.handleTimeEnd = moment(value[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
      // console.log('onOk: ', value);
    },
    // 选人
    userFilter(v,row) {
      let uIds = []
      let uNames = []
      if (row.length > 0) {
        row.forEach(u => {
          uIds.push(u.id)
          uNames.push(u.realname)
        })
        this.filterForm.handlerId = uIds.join(',')
        this.userNames = uNames.join(',')
        this.handleSearch()
      } else {
        this.filterForm.handlerId = ''
        this.userNames = ''
      }
    },
    // 全选
    onCheckAllChange(e) {
      if (e.target.checked) {
        for (let item of this.modelList) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            console.log('each != item.id:',each != item.id)
            return each != item.id
          })
          this.selectedRowKeys.push(item.id)
        }
      } else {
        for (let item of this.modelList) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            console.log('each != item.id:',each != item.id)
            return each != item.id
          })
        }
      }
      this.checkBoxStatus()
    },
    checkBoxStatus() {
      if (this.selectedRowKeys.length == 0) {
        this.listIndeterminate = false
        this.listCheckAll = false
      } else {
        let tableIds = []
        for (let item of this.modelList) {
          tableIds.push(item.id)
        }
        let checkValue = this.isInclude(tableIds, this.selectedRowKeys)
        console.log('第一个参数是；', checkValue)
        if (checkValue) {
          this.listIndeterminate = false
          this.listCheckAll = true
        } else {
          this.listIndeterminate = true
          this.listCheckAll = false
        }
      }
    },
    isInclude(aa, bb) {
      return aa.every((item) => {
        return bb.some((sub) => {
          return sub === item
        })
      })
    },
    // 批量删除
    batchAction() {
      let that = this
      let checkRows = []
      if (that.selectedRowKeys.length > 0) {
        for (let i = 0; i < that.modelList.length; i++) {
          const mod = that.modelList[i];
          for (let j = 0; j < that.selectedRowKeys.length; j++) {
            const sel = that.selectedRowKeys[j];
            if (sel == mod.id && mod.executorStatusText == '已执行') {
              checkRows.push(true)
            }
          }
        }
        if (checkRows.length > 0) {
          that.$antdConfirm({
            title: '无法批量删除',
            content: `所选的处理明细已被执行，不能进行删除！`,
            onOk() {
            },
            onCancel() {},
          })
        } else {
          let ids = that.selectedRowKeys.join(',')
          that.$antdConfirm({
            title: '请确定要删除吗?',
            content: ``,
            onOk() {
              that.clearArr()
              API.messNotQualityHandleIinfoDetailLogicDeleteBatch({ids: ids}).then(res => {
                if (res.code == 200) {
                  that.$antdMessage.success('删除成功！')
                  that.handleSearch()
                } else {
                  that.$antdMessage.error(res.message)
                }
              })
            },
            onCancel() {},
          })
        }
      } else {
        that.$antdMessage.info('请先选择数据')
      }
    },
    /* 清除 */
    clearArr() {
      this.selectedRowKeys = []
      this.checkBoxStatus()
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData(true)
    },
    onShowSizeChange(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData(true)
    },
    handleSearch(selectedKeys, confirm, dataIndex, clearFilters) {
      // confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      // console.log('这都是啥00：', selectedKeys)
      // console.log('这都是啥11：', confirm)
      // console.log('这都是啥22：', dataIndex)
      // console.log('这都是啥33：', clearFilters)
      this.current = 1
      this.requestData()
    },
    /* 打开筛选 */
    handleShowFilter() {
      this.showFilter = true
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    /* 确定筛选 */
    handleFilter() {
      this.handleSearch()
      this.showFilter = false
    },
    /* 删除已选 */
    delFiltered(key) {
      if (key == 'handleType') {
        this.filterForm[key] = undefined
      } else if (key == 'handlerId') {
        this.filterForm[key] = ''
        this.userIds = ''
        this.userNames = ''
      } else if (key == 'handleTime') {
        this.filterForm.handleTimeBegin = ''
        this.filterForm.handleTimeEnd = ''
        this.filterForm[key] = ''
        this.dateForm[key] = null
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        handleType: undefined,
        orderCode: '',
        goodsName: '',
        processName: '',
        handlerId: '',
        handleTime: null,
        handleTimeBegin: '',
        handleTimeEnd: '',
      }
      this.userIds = ''
      this.userNames = ''
      this.dateForm = {}
      this.showFilter = false
      this.handleSearch()
    },
    /* 初始/加载设置列 */
    initData() {
      var oldValue = localStorage.getItem(this.BUSI_CONST.Entity.DEFECTS_DEAL_DETAIL)
      this.columns = getNewColumns(columnsValue, JSON.parse(oldValue), actionArr, this.columns)
    },
    /* 请求列表数据 */
    requestData(check) {
      console.log(this.filterForm)
      let obj = {}
      for(let key in this.filterForm) {
        if (this.filterForm[key]) {
          if (key == 'handleType' && this.filterForm[key]) {
            obj[key] = this.filterForm[key].join(',')
          } else {
            obj[key] = this.filterForm[key]
          }
        }
      }
      let parameter = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...obj,
        ...this.sortForm,
        parentId: this.parentId
      }
      API.messNotQualityHandleIinfoDetailList(parameter).then(res => {
        if (res.code == 200) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          this.modelList = res.result.records
          if (check) {
            this.checkBoxStatus()
          }
        }
      })
    },
    /* 打开设置列面板 */
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData( columnsValue, this.BUSI_CONST.Entity.DEFECTS_DEAL_DETAIL, this.columns)
      })
    },
    /* 设置列 */
    sureBtn(emitArr) {
      this.columns = getNewColumns(columnsValue, emitArr, actionArr)
      console.log(this.columns)
      localStorage.setItem(this.BUSI_CONST.Entity.DEFECTS_DEAL_DETAIL, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    /* 导入 */
    importFile() {},
    /* 导出 */
    exportFile() {},
    /* 新建 */
    handleAdd() {
      this.$router.push('/baseManagement/equipmentRecord/equipmentRecordForm')
    },
    /* 编辑 */
    handleEdit(v) {
      this.$router.push({
        path: '/baseManagement/equipmentRecord/equipmentRecordForm',
        query: { id: v.id }
      })
    },
    /* 详情 */
    handleDetail(v) {
      this.$router.push({
        path: '/baseManagement/equipmentRecord/equipmentRecordDetail',
        query: { id: v.id }
      })
    },
    /* 工单详情 */
    orderDetail(v) {
      this.$refs.windowDetail.initDetail({id: v.orderId})
    },
    /* 删除 */
    handleDelete(v) {
      let that = this
      if (v.executorStatusText == '已执行') {
        that.$antdConfirm({
          title: '无法删除',
          content: `所选的处理明细已被执行，不能进行删除！`,
          onOk() {
          },
          onCancel() {},
        })
      } else {
        that.$antdConfirm({
          title: '请确定要删除此处理明细吗？',
          content: ``,
          onOk() {
            API.messNotQualityHandleIinfoDetailLogicDelete({id: v.id}).then(res => {
              if (res.code == 200) {
                that.$antdMessage.success('删除成功')
              } else {
                that.$antdMessage.error(res.message)
              }
              if (that.modelList.length === 1) {
                that.current = that.current == 1 ? 1 : that.current - 1
              }
              that.requestData()
            })
          },
          onCancel() {},
        })
      }
    },
    //点击返回按钮
    goBack() {
      this.$router.go(-1)
    },
    /* 列表选择 */
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys;
      this.checkBoxStatus()
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.header {
  width: 150%;
  margin: -12px -12px @distance4;
}
.backBox {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .backC {
    cursor: pointer;
    display: flex;
    align-items: center;
  }
}
.j-table-force-nowrap {
  margin-top: @distance1;
}
.btns {
  margin-left: @distance5;
}
.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}
.mg-left {
  margin-left: @distance3;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap:nth-of-type(n+2) {
  margin-top: 10px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
/deep/ .ant-card-body {
  height: calc(100vh - 214px);
  overflow: hidden;
  padding: 20px 16px;
}
</style>
